package com.lisn.mylib.ui.rescue;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;

import com.lisn.mylib.R;
import com.lisn.navannotationlib.FragmentDestination;

@FragmentDestination(pageUrl = "main/tabs/rescue")
public class RescueFragment extends Fragment {

    private RescueViewModel mViewModel;

    public static RescueFragment newInstance() {
        return new RescueFragment();
    }

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {

        mViewModel = new ViewModelProvider(this).get(RescueViewModel.class);

        View root = inflater.inflate(R.layout.fragment_rescue, container, false);
        final TextView text = root.findViewById(R.id.text_rescue);

        mViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
            @Override
            public void onChanged(String s) {
                text.setText(s);
            }
        });
        return root;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

    }

}